import type {IHomeInfo} from "~/types/home";
import {getHomeInfoAPI} from "~/service/home";
import type { HomeInfoDataType } from '~~/service/home'

const homeStore = defineStore('homeStore', {
    state: (): IHomeInfo => {
        return {
            navbars: [],
            banners: [],
            categorys: []
        }
    },
    actions: {
        async fetchHomeData(type: HomeInfoDataType) {
            const { data } = await getHomeInfoAPI(type)
            this.navbars = data.value?.data.navbars || []
            this.banners = data.value?.data.banners || []
            this.categorys = data.value?.data.categorys || []
        }
    }
})
export default homeStore